<?php
class Maillist_Model_Post{
    public $Id;
    public $Subject;
    public $Text;
    /*
     * Дата публикации
     */
    public $Date;
    public $Publish;
    
    public function __construct($options = null){
        if ($options instanceof Maillist_Model_Post)
    	{
    		$options = $options->toArray();
    		$this->setOptions($options);
    	}
        else if (is_array($options)) {
            $this->setOptions($options);
        }
    }
    
    public function setOptions(array $options){
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }
    
    public function toArray(){
    	$vars = get_class_vars(get_class($this));
        foreach ($vars as $var=>$value)
        {
        		$vars[$var] = $this->$var;
        }
        return $vars;
    }
    
    public function getId(){return $this->Id;}
    public function getSubject(){return $this->Subject;}
    public function getText(){return $this->Text;}
    public function getDate(){return $this->Date;}
    public function getPublish (){return $this->Publish;}
    
    public function setId($v){$this->Id=$v;return $this;}
    public function setSubject($v){$this->Subject=$v;return $this;}
    public function setText($v){$this->Text=$v;return $this;}
    public function setDate($v){$this->Date=$v;return $this;}
    public function setPublish($v){$this->Publish=$v;return $this;}
}
?>